package com.scf.fruit.business.commodity.bo;

import com.github.pagehelper.PageHelper;
import com.scf.fruit.commodity.CommodityDto;
import com.scf.fruit.commodity.CommodityService;
import com.scf.fruit.util.ResponseVo;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author : 孙超飞
 * @title :
 * @description :
 * @copyright :
 * @date : 2018-05-21 15:41
 */
@Component
public class CommodityBo {
    @Resource
    private CommodityService commodityService;

    public ResponseVo queryCommodityByPage(Integer pageNum, Integer length){
        ResponseVo res=new ResponseVo();
        PageHelper.startPage(pageNum,length,false);
        List<CommodityDto> commodityDtos = commodityService.queryCommodityByPage();
        res.setData(commodityDtos);
        return res;
    }


    public ResponseVo queryCommodityByType(Integer type,Integer pageNum, Integer length){
        ResponseVo res=new ResponseVo();
        PageHelper.startPage(pageNum,length,false);
        List<CommodityDto> commodityDtos = commodityService.queryCommodityByType(type);
        res.setData(commodityDtos);
        return res;
    }

}
